<?php

require('PHPExcel.php');

class Excel extends PHPExcel {

    //var $company_name = "Company Name";
    var $title = "Report Title";

    function title($title) {
        $this->title = substr($title, 0, 29);
        $this->setActiveSheetIndex(0);
        $this->getActiveSheet()->setTitle($title);
    }

    function setHeaderCol($pos, $title) {
        $this->getActiveSheet()->SetCellValue($pos, $title);
        $this->getActiveSheet()->getStyle($pos)->getFont()->setName('Tahoma');
        $this->getActiveSheet()->getStyle($pos)->getFont()->setSize(11);
        $this->getActiveSheet()->getStyle($pos)->getAlignment()->setVertical(PHPExcel_Style_Alignment::VERTICAL_CENTER);
        $this->getActiveSheet()->getStyle($pos)->getFill()->setFillType(PHPExcel_Style_Fill::FILL_SOLID);
        $this->getActiveSheet()->getStyle($pos)->getFill()->getStartColor()->setARGB('C0C0C0C0');
        //$this->getActiveSheet()->getStyle($pos)->getBorders()->getTop()->setBorderStyle(PHPExcel_Style_Border::BORDER_THIN);
        $this->getActiveSheet()->getStyle($pos)->getAlignment()->setHorizontal(PHPExcel_Style_Alignment::HORIZONTAL_CENTER);
        return $this;
    }

    function setColWidth($col, $width) {
        $this->getActiveSheet()->getColumnDimension($col)->setWidth($width);
    }

    function setDetailCol($pos, $title) {
        
        $this->getActiveSheet()->SetCellValue($pos, $title);
    }

    function output() {
        header('Content-Type: application/vnd.openxmlformats-officedocument.spreadsheetml.sheet');
        header('Content-Disposition: attachment;filename="' . $this->title . '.xlsx"');
        header('Cache-Control: max-age=0');
        $objWriter = PHPExcel_IOFactory::createWriter($this, 'Excel2007');
        $objWriter->save('php://output');
    }

}

?>
